package JavaSEAdvance.day05_API;

/**
 * @author Xiao
 * @date 2021/7/21
 */
public class d501_MathDemo01 {
    /**
     * Math
     */
    public static void main(String[] args) {
        System.out.println(Math.abs(-2.5));     //绝对值 2.5
        System.out.println(Math.ceil(2.5));     //向上取整  3.0
        System.out.println(Math.floor(2.5));    //向下取整  2.0
        System.out.println(Math.max(2, 3));     //最大值   3
        System.out.println(Math.min(2, 3));     //最小值   2
        System.out.println(Math.round(2.4));    //四舍五入  2
        System.out.println(Math.round(2.5));    //四舍五入  3
        System.out.println(Math.random() * 10);   //随机数[0,1)  5.389935477736466 → double[0,10)
        System.out.println((int) (Math.random() * 10 + 1));   //随机数[0,1)  3 → int[1,10]
        System.out.println(Math.pow(2, 3));     //a的b次幂 8.0
    }
}
